package com.ygo.feihua;

import com.cc.chioceFileListView.BitmapOptimization;
import com.ygo.feihua.BmobTable.*;

import java.io.*;
import java.text.*;
import java.util.*;

import android.provider.*;
import cn.bmob.v3.*;
import android.support.v7.app.AppCompatActivity;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Button;
import android.widget.TextView;
import cn.bmob.v3.datatype.BmobFile;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.content.Intent;
import cn.bmob.v3.listener.UploadFileListener;
import cn.bmob.v3.listener.SaveListener;
import cn.bmob.v3.exception.BmobException;
import android.support.v4.view.*;
import android.support.v4.app.*;
import android.util.*;
import com.ygo.feihua.fragment.*;

public class ZhutiShangchuan extends AppCompatActivity 
{
	
	
	//主题截图
	public List<String> zt_jt;
	//主题名字,主题简介
	public String zt_name,zt_js;
	//主题路径,图标路径
	public String path_zt,path_tubiao;
	//上传按钮
 	public Button sc_sc;
	//主题大小
	public Integer zt_size=0;
	
	public Gongju gj;
	public FragmentManager fragmentManager;
	public FragmentZsZs fagzs;
	
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		// TODO: Implement this method
		super.onCreate(savedInstanceState);
		setContentView(R.layout.zhuti_shangchuan);
		
		gj =Gongju.getdx(ZhutiShangchuan.this);
		
		sc_sc=(Button) findViewById(R.id.sc_sc);
		
		fagzs=new FragmentZsZs();
		fragmentManager=getSupportFragmentManager();
		
		zt_jt=new ArrayList<String>();
		
		gj.cshToolbar((Toolbar) findViewById(R.id.toolbar),"主题上传");
		
		fragmentcsh();
	}

	private void fragmentcsh(){
		fragmentManager.beginTransaction().replace(R.id.sc_frage, new FragmentZsName()).commit();
		// TODO: Implement this method
	}
	
	@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) 
    {
        super.onActivityResult(requestCode, resultCode, data);
        FragmentManager fragmentManager=getSupportFragmentManager();
        for(int indext=0;indext<fragmentManager.getFragments().size();indext++)
        {
            Fragment fragment=fragmentManager.getFragments().get(indext); //找到第一层Fragment
            if(fragment!=null)
                handleResult(fragment,requestCode,resultCode,data);
        }
    }
    /**
     * 递归调用，对所有的子Fragment生效
     * @param fragment
     * @param requestCode
     * @param resultCode
     * @param data
     */
    private void handleResult(Fragment fragment,int requestCode,int resultCode,Intent data) 
    {
        fragment.onActivityResult(requestCode, resultCode, data);//调用每个Fragment的onActivityResult
        
        List<Fragment> childFragment = fragment.getChildFragmentManager().getFragments(); //找到第二层Fragment 
        if(childFragment!=null)
            for(Fragment f:childFragment)
                if(f!=null)
                {
                    handleResult(f, requestCode, resultCode, data);
                }
    }
}
